package com.demo.spring.repository;

import com.demo.spring.model.User;
import com.demo.spring.model.UserVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long> {

    @Query("select u from User u where u.name like %?1% ")
    List<User> queryName(String name);

    @Query("select new com.demo.spring.model.UserVo(u.name, u.password) from User u where u.id = 1")
    UserVo queryUserVo();
}
